# Provides access to the Verboice Public API.
#
# === Install
#
#   gem install verboice
#
# === Example
#
#   api = Verboice.new 'service_url', 'account_name', 'account_password', 'channel'
require 'rubygems'
require 'httparty'
require 'json'

# Provides access to the Verboice Public API.
class Verboice
  include HTTParty

  # Creates an application-authenticated Verboice api access.
  def initialize(url, account, password, default_channel = nil)
    @url = url
    @account = account
    @password = password
    @default_channel = default_channel
    @auth = {:username => account, :password => password}
  end
  
  def call address, channel = @default_channel
    self.class.get "#{@url}/api/call", :query => {:channel => channel, :address => address}, :basic_auth => @auth
  end

end
